package com.tiheima.model.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class PageQuery {
    private Integer page;
    private Integer pageSize;

    private static final Integer DEFAULT_PAGE = 1;
    private static final Integer DEFAULT_PAGE_SIZE = 10;

    // pageHelper插件已经帮我们做了
    // reasonable: true
    public void checkPageParam() {
        if (page == null || page < DEFAULT_PAGE) {
            page = DEFAULT_PAGE;
        }
        if (pageSize == null || pageSize < DEFAULT_PAGE) {
            pageSize = DEFAULT_PAGE_SIZE;
        }
    }
}
